<script src="<?php echo base_url() ?>commons/js/validacion.js" type="text/javascript"></script>
<script src="<?php echo base_url() ?>commons/validacion/js/jquery-1.8.2.min.js" type="text/javascript"></script>
<link href="<?php echo base_url() ?>commons/validacion/css/validationEngine.jquery.css" rel="stylesheet"/>
<script src="<?php echo base_url() ?>commons/validacion/js/languages/jquery.validationEngine-es.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo base_url() ?>commons/validacion/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="<? echo base_url() ?>commons/jquery/themes/base/jquery.ui.all.css"/>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.core.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.widget.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.tabs.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/jquery.ui.datepicker.js"></script>
<script src="<?php echo base_url() ?>commons/jquery/ui/i18n/jquery.ui.datepicker-es.js"></script>
<script>
    var nt1 = jQuery.noConflict();
    nt1(function() {
        nt1(".calendario").datepicker(nt1.datepicker.regional[ "es" ]);

    });
</script>
<script>
    var t1 = jQuery.noConflict();
    t1(function() {
        t1("#tabs").tabs();
    });
</script>
<script type="text/javascript">
    var t1 = jQuery.noConflict();
    t1(function() {
        ocultar_mostrar_doc(0);
    });
    function ocultar_mostrar_doc(opc) {
        var panel0 = document.getElementById("panel0");
        var panel1 = document.getElementById("panel1");
        var panel2 = document.getElementById("panel2");
        var panel3 = document.getElementById("panel3");
        var panel4 = document.getElementById("panel4");
        //var panel5 = document.getElementById("panel5");
        //var panel6 = document.getElementById("panel6");
        var panel7 = document.getElementById("panel7");
        
        opc = opc * 1;
        switch (opc) {
            case 0:
                panel0.style.display = "block";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "none";
                break
            case 1:
                panel0.style.display = "none";
                panel1.style.display = "block";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "none";
                break
            case 2:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "block";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "none";

                break
            case 3:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "block";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "none";

                break
            case 4:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "block";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "none";
                break

            case 5:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'block';
                //panel6.style.display = 'none';
                panel7.style.display = "none";
                break
            case 6:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'block';
                panel7.style.display = "none";
                break
            case 7:
                panel0.style.display = "none";
                panel1.style.display = "none";
                panel2.style.display = "none";
                panel3.style.display = "none";
                panel4.style.display = "none";
                //panel5.style.display = 'none';
                //panel6.style.display = 'none';
                panel7.style.display = "block";
                break

        } //fin switch
    }

    function ocultar_mostrar_fin(opc) {

        var panel1 = document.getElementById("panel_pagoi1");
        var panel2 = document.getElementById("panel_pagoi2");
        var panel3 = document.getElementById("panel_financia");
        var panel4 = document.getElementById("idcosto_arrastre");
        var panel5 = document.getElementById("idcosto_tit");
        var panel6 = document.getElementById("panel_coutas");



        opc = opc * 1;

        switch (opc) {
            case 1:  //contado
            case 2:  //iece
            case 3:  //becas 100
            case 8:
            case 9:
            case 10:
                panel1.style.display = 'block';
                panel4.style.display = 'block';
                panel5.style.display = 'block';
                panel2.style.display = 'none';
                panel3.style.display = 'none';
                panel6.style.display = 'none';

                break
            case 4: //beca 75
            case 5: //beca 50
            case 6: //beca 25
            case 7: //finaciado
            case 11://IECE Financiado
                panel1.style.display = 'none';
                panel4.style.display = 'none';
                panel5.style.display = 'none';
                panel2.style.display = 'block';
                panel3.style.display = 'block';
                panel6.style.display = 'block';
                break

        } //fin switch

    }
    function mostrar_tabla() {
        var boton = document.getElementById("ver_tabla");
        var tabla = document.getElementById("tablamatriculai");
        var valor = boton.value;
        if (valor.toLowerCase() == "mostrar") {
            boton.value = "ocultar";
            tabla.style.display = 'block';
        } else {
            boton.value = "mostrar";
            tabla.style.display = 'none';

        }

    }
</script>
<script>
    var t = jQuery.noConflict();
    t(document).ready(function() {
        // binds form submission and fields to the validation engine			
        // t("#formID").validationEngine();
        t("#formID1").validationEngine();
        t("#formID3").validationEngine();
        t("#formIDR1").validationEngine();

    });

    function checkHELLO(field, rules, i, options) {
        if (field.val() != "HELLO") {
            // this allows to use i18 for the error msgs
            return options.allrules.validate2fields.alertText;
        }
    }
</script>
<?php
$ci = &get_instance();
$ci->load->model("Coutas_Model");
echo '<script type="text/javascript">';
echo 'var t = jQuery.noConflict(); ';
echo 't(document).ready(function(){
	setTimeout(function(){ t(".mensajes").fadeOut(800).fadeIn(800).fadeOut(500).fadeIn(500).fadeOut(300);}, 3000); ';
echo '		});';
echo '</script>';
echo validation_errors('<div class="error">', '</div>');
if ($this->session->flashdata('error')) {
    echo "<div class='error mensajes'>";
    echo $this->session->flashdata('error');
    echo "</div>";
}
if ($this->session->flashdata('info')) {
    echo "<div class='info mensajes'>";
    echo $this->session->flashdata('info');
    echo "</div>";
}
//alerta
if ($this->session->flashdata('exito')) {
    echo "<div class='info mensajes'>";
    echo $this->session->flashdata('exito');
    echo "</div>";
}
if ($this->session->flashdata('alerta')) {
    echo "<div class='info mensajes'>";
    echo $this->session->flashdata('alerta');
    echo "</div>";
}
?>

<!--<form id="formID1" class="well form-horizontal span8" action="<?php echo base_url() . "admin.php/coutas/ingresocoutas" ?>"  method="post" >-->
<div class="well form-horizontal span8"  >
    <legend>PROCESAR DATOS DE COBROS</legend>

    <div class="tabbable">
        <ul class="nav nav-tabs">
            <li ><a href="#1" data-toggle="tab">Datos Generales</a></li>
            <li><a href="#2" data-toggle="tab">Datos Matriculaci&oacute;n</a></li>
            <li class="active"><a href="#3" data-toggle="tab">Cobros</a></li>
            <li><a href="#4" data-toggle="tab">Rubros</a></li>
            <?php if ($totalPagadoS == 0) { ?>
                <li><a href="#5" data-toggle="tab">Pago inicial</a></li>
            <?php } ?>
            <li><a href="#6" data-toggle="tab">Refinanciamiento</a></li>
        </ul>
        <div class="tab-content">
            <?php foreach ($estudiante as $i => $est) { ?>
                <div class="tab-pane" id="1">
                    <div class="control-group">
                        <label class="control-label" for="input01">N&uacute;mero de Identificaci&oacute;</label>
                        <div class="controls">
                            <input type="text" class="input-medium span2"  name="cedula_pers" value= "<?php echo $est['cedula_pers']; ?>">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="select01">Tipo de Documento</label>
                        <div class="controls">

                            <select id="select01"  name="tipo_doc_pers">

                                <option value= "0" <?php echo ($est['tipo_doc_pers'] == 0 ? " selected" : " "); ?>>CEDULA</option>
                                <option value= "1" <?php echo ($est['tipo_doc_pers'] == 1 ? " selected" : " "); ?>>PASAPORTE</option>
                                <option value= "2" <?php echo ($est['tipo_doc_pers'] == 2 ? " selected" : " "); ?>>CARNE DE REFUGIADO</option>
                            </select>

                        </div>
                    </div>


                    <div class="control-group">
                        <label class="control-label" for="input02">Nombre Completos</label>
                        <div class="controls">
                            <input type="text" class="input-medium span4"  name="nombre_pers" value= "<?php echo $est['nombre_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input03">Apellidos </label>
                        <div class="controls">
                            <input type="text" class="input-medium span4"  name="apellido_pers" value= "<?php echo $est['apellido_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input04">Nacionalidad </label>
                        <div class="controls">
                            <input type="text" class="input-medium span3"  name="nacionalidad_pers" value= "<?php echo $est['nacionalidad_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input15">Provincia </label>
                        <div class="controls">
                            <input type="text" class="input-medium span3"  name="provincia_pers" value= "<?php echo $est['provincia_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input05">Ciudad </label>
                        <div class="controls">
                            <input type="text" class="input-medium span3"  name="ciudad_pers" value= "<?php echo $est['ciudad_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input06">Direccion del Domicilio</label>
                        <div class="controls">
                            <input type="text" class="input-medium span4"  name="direccion_pers" value= "<?php echo $est['direccion_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input07">Referencia del Domicilio</label>
                        <div class="controls">
                            <input type="text" class="input-medium span4"  name="refer_domic_pers" value= "<?php echo $est['refer_domic_pers']; ?>">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input08">Tipo de Discapacidad</label>
                        <div class="controls">
                            <input type="text" class="input-medium span4"  name="tipo_discap_pers" value= "<?php echo $est['tipo_discap_pers']; ?>">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input09">Carn&eacute; del CONADIS</label>
                        <div class="controls">
                            <input type="text" class="input-medium span3"  name="conadis_pers" value= "<?php echo $est['conadis_pers']; ?>">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input010">Porcentaje de Discapacidad</label>
                        <div class="controls">
                            <input type="text" class="input-medium span2"  name="porc_disc_pers" value= "<?php echo $est['porc_disc_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="select01">Sexo</label>
                        <div class="controls">

                            <select id="select01"  name="sexo_pers">
                                <option <?php echo ($est['sexo_pers'] == "HOMBRE" ? " selected" : " "); ?>>HOMBRE</option>
                                <option <?php echo ($est['sexo_pers'] == "MUJER" ? " selected" : " "); ?>>MUJER</option>
                            </select>

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="select02">Estado Civil</label>
                        <div class="controls">

                            <select id="select02"  name="estado_civil_pers">
                                <option <?php echo ($est['estado_civil_pers'] == "SOLTERO(A)" ? " selected" : " "); ?>>SOLTERO(A)</option>
                                <option <?php echo ($est['estado_civil_pers'] == "CASADO(A)" ? " selected" : " "); ?>>CASADO(A)</option>
                                <option <?php echo ($est['estado_civil_pers'] == "UNION LIBRE" ? " selected" : " "); ?>>UNION LIBRE</option>
                                <option <?php echo ($est['estado_civil_pers'] == "DIVORCIADO(A)" ? " selected" : " "); ?>>DIVORCIADO(A)</option>
                                <option <?php echo ($est['estado_civil_pers'] == "VIUDO(A)" ? " selected" : " "); ?>>VIUDO(A)</option>
                                <option <?php echo ($est['estado_civil_pers'] == "ECLECIASTICO(A)" ? " selected" : " "); ?>>ECLECIASTICO(A)</option>


                            </select>

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="select12">Autodefinici&oacute;</label>
                        <div class="controls">

                            <select id="select02"  name="autodefin_pers">
                                <option <?php echo ($est['autodefin_pers'] == "NEGRO" ? " selected" : " "); ?>>NEGRO</option>
                                <option <?php echo ($est['autodefin_pers'] == "MULATO" ? " selected" : " "); ?>>MULATO</option>
                                <option <?php echo ($est['autodefin_pers'] == "AFROECUATORIANO" ? " selected" : " "); ?>>AFROECUATORIANO</option>
                                <option <?php echo ($est['autodefin_pers'] == "INDIGENA" ? " selected" : " "); ?>>INDIGENA</option>
                                <option <?php echo ($est['autodefin_pers'] == "MESTIZO" ? " selected" : " "); ?>>MESTIZO</option>
                                <option <?php echo ($est['autodefin_pers'] == "MONTUBIO" ? " selected" : " "); ?>>MONTUBIO</option>
                                <option <?php echo ($est['autodefin_pers'] == "BLANCO" ? " selected" : " "); ?>>BLANCO</option>
                                <option <?php echo ($est['autodefin_pers'] == "OTRO" ? " selected" : " "); ?>>OTRO</option>


                            </select>

                        </div>
                    </div>


                    <div class="control-group">
                        <label class="control-label" for="select03">Fecha de Nacimiento</label>
                        <div class="controls">
                            <input type="text" class="input-medium "  name="fecha_nac_pers" value="<?php echo date("m/d/Y", strtotime($est['fecha_nac_pers'])); ?>">

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input08">N&uacute;mero de tel&eacute;fono</label>
                        <div class="controls">
                            <input type="text" class="input-medium span2"  name="fono_pers" value= "<?php echo $est['fono_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input09">N&uacute;mero de celular</label>
                        <div class="controls">
                            <input type="text" class="input-medium span2"  name="celular_pers" value= "<?php echo $est['celular_pers']; ?>">

                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label" for="input10">Correo Electr&oacute;nico Institucional</label>
                        <div class="controls">
                            <input type="text" class="input-medium span3"  name="email_inst_pers" value= "<?php echo $est['email_inst_pers']; ?>">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input11">Fotograf&iacute;a</label>
                        <div class="controls">
                            <img src="<?php echo $est['foto_pers']; ?>" width="88" height="99" alt="itss1"/>
                        </div>
                    </div>



                </div>



            <?php } ?>
            <div class="tab-pane" id="2">

                <div class="control-group">
                    <label class="control-label" for="select01">PERIODO</label>
                    <div class="controls ">
                        <select name="ide_lec" class="span3">
                            <option ><?php echo $ide_lec_nom; ?></option>
                        </select>

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="select03">CARRERA</label>
                    <div class="controls ">
                        <select name="ide_car" class="span3" >
                            <option ><?php echo $ide_car_nom; ?></option>
                        </select>

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="select03">Pensums</label>
                    <div class="controls ">
                        <select id="select02" name="ide_pen" class="span3">
                            <option ><?php echo $ide_pen_nom; ?></option>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="select04">Ciclo</label>
                    <div class="controls ">
                        <select id="select02" name="ide_ciclo" class="span3">

                            <option ><?php echo $ide_ciclo_nom; ?></option>
                        </select>
                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="select02">JORNADA DE TRABAJO</label>
                    <div class="controls ">
                        <select name="seccion" class="span3">
                            <option ><?php echo $seccion_nom; ?></option>
                        </select>


                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="select02">PARALELO</label>
                    <div class="controls ">
                        <select name="paralelo" class="span1">
                            <option ><?php echo $paralelo_nom; ?></option>
                        </select>


                    </div>
                </div>


                <div class="control-group">
                    <label class="control-label" for="select08">Fecha de la Matr&iacute;cula</label>
                    <div class="controls">

                        <input type="text" class="input-medium "  name="fecha_matr" value="<?php echo date("m/d/Y"); ?>" >

                    </div>
                </div>

                <div class="control-group">
                    <label class="control-label" for="input02">Nro. de Matr&iacute;cula</label>
                    <div class="controls">
                        <input type="text" class="input-medium span1"  name="nro" value="<?php echo $nro_mat; ?>" disabled>

                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="select02">MODO DE MATRICULA</label>
                    <div class="controls ">
                        <select name="modo_mat" class="span2" disabled>
                            <option value="1" <?php echo ($modo_mat == 1 ? " selected" : " "); ?>>NORMAL</option>
                            <option value="2" <?php echo ($modo_mat == 2 ? " selected" : " "); ?>>NORMAL/ARRASTRE</option>
                            <!-- <option value="3">SOLO ARRASTRES</option> -->
                            <option value="3" <?php echo ($modo_mat == 3 ? " selected" : " "); ?>>CONVALIDACION</option>
                            <option value="4" <?php echo ($modo_mat == 4 ? " selected" : " "); ?>>POR MATERIAS</option>

                        </select>


                    </div>
                </div>    

                <div class="control-group">
                    <label class="control-label" for="textarea">OBSERVACION</label>
                    <div class="controls">
                        <textarea class="input-xxlarge" id="observa_cur" name="observa_cur" rows="2" value=""></textarea>
                    </div>
                </div>




            </div>  <!--fin tabulador 2 -->
            <div class="tab-pane active" id="3">
                <form id="formID1" class="well form-horizontal span8" action="<?php echo base_url() . "admin.php/coutas/ingresocoutas/" . $ide_matr ?>"  method="post" >
                    <input type="hidden" id="ide_matricula" name="ide_matr" value="<?php echo $ide_matr; ?>">
                    <input type="hidden" id="ide_lectivos" value="<?php echo $ide_lec?>" name="ide_lec1"/>
                    <script>
                        function sumar(n, m, r) {
                            var suma = (n.value * 1) - (m.value * 1);
                            r.value = suma.toFixed(2);
                        }
                        function refinancia(n, m, r, s) {
                            var suma = (s.value * 1) + r.value * 1;
                            s.value = suma.toFixed(2);
                            n.value = m.value * 1;
                            r.value = 0;
                            //alert (n.value*1);
                        }
                        function calcularSumaTabla(tablaR){
                            var suma = 0;
                            for (var i = 1; i < tablaR.rows.length; i++) {
                                var id = tablaR.rows[i].cells[0].getElementsByTagName('input');
                                var valor = tablaR.rows[i].cells[1].getElementsByTagName('input');
                                if(id[0].checked==true){
                                    suma = suma + (valor[0].value*1);
                                }                                 
                            }
                            return suma;
                        }
                        function Acancelar() {
                            /*var valores = new Array();
                            t("input[type=checkbox]:checked").each(function(suma) {
                                //cada elemento seleccionado                                
                                nombre = t(this).val();
                                x = (document.getElementById("" + nombre).value * 1);
                                valores.push(x);
                            });
                            suma = 0;
                            t.each(valores, function(index, contenido) {
                                suma = suma + contenido;
                            });*/
                            var suma = 0;
                            if(document.getElementById('tabla_cuotas_semestre')){
                                suma = suma+calcularSumaTabla(document.getElementById('tabla_cuotas_semestre'));
                            }
                            if(document.getElementById('tabla_cuotas_arrastre')){
                                suma = suma+calcularSumaTabla(document.getElementById('tabla_cuotas_arrastre'));
                            }
                            //var tablaS = document.getElementById('tabla_cuotas_semestre');
                            //var tablaA = document.getElementById('tabla_cuotas_arrastre');
                            
                            document.getElementById("cancelar").value = (Math.round(suma * 100) / 100);
                        }
                        function cambiarvalor(ch,n, m) {
                            
                        //check = document.getElementById("chkpago_p");
                        if (ch.checked) {
                            m.value = n.value * 1;
                        }
                        else {
                            m.value = 0;
                        }                    
                            
                            
                            //alert (n.value*1);
                        }
                        

                    </script>
                    <div class="control-group">
                        <label class="control-label" for="select08">Fecha de la Cobro</label>
                        <div class="controls">

                            <input type="text" class="input-medium "  id="datepicker" name="fecha_matr" value="<?php echo date("m/d/Y"); ?>" />

                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="input31">Forma de Pago</label>
                        <div class="controls">
                            <select id="tipo_matr" name="tipo_doc_pago_mat" class="span2" ONCHANGE="javascript:ocultar_mostrar_doc(this.options[this.selectedIndex].value)">
                                <option value="0" >SELECCIONE UN DOCUMENTO</option>
                                <option value="1" >EFECTIVO</option>
                                <option value="2" >CHEQUE</option>
                                <option value="3" >DEPOSITO</option>
                                <option value="4" >TARJETA</option>
                                <option value="7" >TRANSFERENCIA</option>
                                <!--<option value="5" >EFECTIVO-CHEQUE</option>
                                <option value="6" >EFECTIVO-DEPOSITO</option>
                                <option value="7" >EFECTIVO-TARJETA</option>-->


                            </select>


                        </div>
                    </div>
                    <!--INICIO_-->
                    <script>
                        function validarP1(){
                            
                            var monto_efec_doc_pago = document.getElementById("monto_efec_doc_pago1");
                            if(requerido(monto_efec_doc_pago)==false){
                                return false;
                            }else if(validarNumero(monto_efec_doc_pago)==false){
                                return false;
                            }else if(minimo(monto_efec_doc_pago,-1)==false){
                                return false;
                            }
                            return true;
                        }
                        function validarP2(){
                            var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat2");
                            var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat2");
                            var fecha_doc = document.getElementById("fecha_doc2");
                            var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat2");                            
                            var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago2");
                            
                            if(requerido(nom_doc_pago_mat)==false){
                                return false;
                            }else if(requerido(nro_comp_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(fecha_doc)==false){
                                return false;
                            }
                            else if(requerido(ref_doc_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(monto_rest_doc_pago)==false){
                                return false;
                            }else if(validarNumero(monto_rest_doc_pago)==false){
                                return false;
                            }else if(minimo(monto_rest_doc_pago,-1)==false){
                                return false;
                            }
                            return true;
                        }
                        function validarP3(){
                            //var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat3");
                            var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat3");
                            var fecha_doc = document.getElementById("fecha_doc3");
                            var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat3");                            
                            var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago3");
                            
                            //if(requerido(nom_doc_pago_mat)==false){
                              //  return false;
                            //}else
                                if(requerido(nro_comp_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(fecha_doc)==false){
                                return false;
                            }
                            else if(requerido(ref_doc_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(monto_rest_doc_pago)==false){
                                return false;
                            }else if(validarNumero(monto_rest_doc_pago)==false){
                                return false;
                            }else if(minimo(monto_rest_doc_pago,-1)==false){
                                return false;
                            }
                            return true;
                        }
                        function validarP4(){
                            //var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat3");
                            var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat4");
                            var fecha_doc = document.getElementById("fecha_doc4");
                            var lote_doc_pago_mat = document.getElementById("lote_doc_pago_mat4");
                            var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat4");                            
                            var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago4");
                            //alert(monto_rest_doc_pago.value);
                            //if(requerido(nom_doc_pago_mat)==false){
                              //  return false;
                            //}else
                            if(requerido(nro_comp_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(fecha_doc)==false){
                                return false;
                            }
                            else if(requerido(lote_doc_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(ref_doc_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(monto_rest_doc_pago)==false){
                                return false;
                            }else if(validarNumero(monto_rest_doc_pago)==false){
                                return false;
                            }else if(minimo(monto_rest_doc_pago,-1)==false){
                                return false;
                            }
                            return true;
                        }
                        function validarP7(){
                            var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat7");
                            var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat7");
                            var fecha_doc = document.getElementById("fecha_doc7");
                            //var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat2");                            
                            var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago7");
                            
                            if(requerido(nom_doc_pago_mat)==false){
                                return false;
                            }else if(requerido(nro_comp_pago_mat)==false){
                                return false;
                            }
                            else if(requerido(fecha_doc)==false){
                                return false;
                            }
                            
                            else if(requerido(monto_rest_doc_pago)==false){
                                return false;
                            }else if(validarNumero(monto_rest_doc_pago)==false){
                                return false;
                            }else if(minimo(monto_rest_doc_pago,-1)==false){
                                return false;
                            }
                            return true;
                        }
                    </script>
                      
           
                    <script>
                        function cargarDatosPanle(nro){
                            //alert(nro);
                            var tipo = document.getElementsByName("tipo" + nro);
                            var nom_doc_pago_mat = document.getElementsByName("nom_doc_pago_mat" + nro);
                            var nro_comp_pago_mat = document.getElementsByName("nro_comp_pago_mat" + nro);
                            var lote_doc_pago_mat = document.getElementsByName("lote_doc_pago_mat" + nro);
                            var fecha_doc = document.getElementsByName("fecha_doc" + nro);
                            var monto_efec_doc_pago = document.getElementsByName("monto_efec_doc_pago" + nro);
                            var monto_rest_doc_pago = document.getElementsByName("monto_rest_doc_pago" + nro);                                                        
                            var ref_doc_pago_mat = document.getElementsByName("ref_doc_pago_mat" + nro);                                                        
                            
                            var combo = document.getElementById("tipo_matr");                            
                            var documento = "";
                            if(nom_doc_pago_mat[0].type=="select-one"){
                                //alert("hades "+nom_doc_pago_mat[0].options[nom_doc_pago_mat[0].selectedIndex].value);
                                documento = nom_doc_pago_mat[0].options[nom_doc_pago_mat[0].selectedIndex].value;
                            }else{
                                documento = nom_doc_pago_mat[0].value;
                            }
                           // 
                            var data1 = "tipo=" + tipo[0].value + 
                                    "&nom_doc=" + documento +
                                    "&nro_comp=" +nro_comp_pago_mat[0].value+ 
                                    "&lote=" +lote_doc_pago_mat[0].value+ 
                                    "&fecha=" +fecha_doc[0].value+ 
                                    "&efectivo=" +monto_efec_doc_pago[0].value+
                                    "&referencia=" +ref_doc_pago_mat[0].value+
                                    "&pago=" +monto_rest_doc_pago[0].value;
                            //alert(data1+" nada");
                            combo[0].selected=true;
                            ocultar_mostrar_doc(0);
                             t.ajax({
                                    type: "POST", 
                                    url: "<?php echo base_url(); ?>admin.php/coutas/agregarDocumentosLista/",
                                    data: data1,
                                    dataType: "html",
                                    success: (function(data) {
                                         // alert(data);
                                        t("#tbldoc").html(data);
                                    })
                                });                           
                        }
                        function cargarDatosTabla(){
                            t.ajax({
                                    type: "POST", 
                                    url: "<?php echo base_url(); ?>admin.php/coutas/tablaDocumentos/",                                    
                                    dataType: "html",
                                    success: (function(data) {
                                         // alert(data);
                                        t("#tbldoc").html(data);
                                    })
                                });
                            //nom_doc_pago
                            
                           
                            
                        }
                        t(document).ready(function() {
        // binds form submission and fields to the validation engine			
        // t("#formID").validationEngine();
       cargarDatosTabla();

    });
                        function agregarPanel(nro) {
                            //alert('xxx');
                            if(nro==1){
                                if(validarP1()==true){
                                    cargarDatosPanle(nro);  
                                    var monto_efec_doc_pago = document.getElementById("monto_efec_doc_pago1");
                                    monto_efec_doc_pago.value = "0";
                                }
                            }
                            if(nro==2){
                                if(validarP2()==true){
                                    cargarDatosPanle(nro);
                                    var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat2");
                                    var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat2");
                                    var fecha_doc = document.getElementById("fecha_doc2");
                                    var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat2");                            
                                    var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago2");
                                    nom_doc_pago_mat.value="";
                                    nro_comp_pago_mat.value="";
                                    fecha_doc.value="";
                                    ref_doc_pago_mat.value="";
                                    monto_rest_doc_pago.value="0";
                                }
                            }
                            if(nro==3){
                                if(validarP3()==true){
                                    cargarDatosPanle(nro);
                                    var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat3");
                                    var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat3");
                                    var fecha_doc = document.getElementById("fecha_doc3");
                                    var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat3");                            
                                    var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago3");                                    
                                    nom_doc_pago_mat[0].selected=true;
                                    nro_comp_pago_mat.value="";
                                    fecha_doc.value="";
                                    ref_doc_pago_mat.value="";
                                    monto_rest_doc_pago.value="0";
                                }
                            }
                            if(nro==4){
                                if(validarP4()==true){
                                    cargarDatosPanle(nro);
                                    var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat4");
                                    var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat4");
                                    var fecha_doc = document.getElementById("fecha_doc4");
                                    var lote_doc_pago_mat = document.getElementById("lote_doc_pago_mat4");
                                    var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat4");                            
                                    var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago4");
                                    nom_doc_pago_mat[0].selected=true;
                                    nro_comp_pago_mat.value="";
                                    fecha_doc.value="";
                                    ref_doc_pago_mat.value="";
                                    lote_doc_pago_mat.value="";
                                    monto_rest_doc_pago.value="0";
                                }
                            }
                            if(nro==7){
                                if(validarP7()==true){
                                    cargarDatosPanle(nro);
                                    var nom_doc_pago_mat = document.getElementById("nom_doc_pago_mat7");
                                    var nro_comp_pago_mat = document.getElementById("nro_comp_pago_mat7");
                                    var fecha_doc = document.getElementById("fecha_doc7");
                                    //var ref_doc_pago_mat = document.getElementById("ref_doc_pago_mat2");                            
                                    var monto_rest_doc_pago = document.getElementById("monto_rest_doc_pago7");
                                    nom_doc_pago_mat.value=true;
                                    nro_comp_pago_mat.value="";
                                    fecha_doc.value="";
                                    monto_rest_doc_pago.value="0";
                                }
                            }
                            //alert(tipo[0].value);
                        }
                    </script>
                    <div id="panel0" style="display: none;">
                        <div class="control-group">

                            <label style="color: black; font-weight: bold;">Seleccione una forma de pago</label>
                        </div> 


                    </div>

                    <div id="panel1" style="display: none;">
                        
                            <input type="hidden" name="tipo1" value="1" />
                            <input type="hidden" name="nom_doc_pago_mat1"  value="EFECTIVO"/>
                            <input type="hidden" name="nro_comp_pago_mat1" value="NINGUNO"/>
                            <input type="hidden" name="lote_doc_pago_mat1" value="NINGUNO"/>
                            <input type="hidden" name="ref_doc_pago_mat1" value="NINGUNO"/>

                            <input type="hidden" name="fecha_doc1" value="<?php echo date("m/d/Y"); ?>"/>
                            <div class="control-group">
                                <label class="control-label" >VALOR EN EFECTIVO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1],custom[number],min[1]]" id="monto_efec_doc_pago1"  name="monto_efec_doc_pago1" value="0" />

                                </div>
                            </div>                        
                            <input type="hidden" name="monto_rest_doc_pago1" value="0"/>
                            <div class="control-group">
                                <div class="controls">
                                    
                                   <a href="#"  onclick="return agregarPanel(1)">AGREGAR</a>
                                </div>
                            </div>                        
                       
                    </div>
                    <div id="panel2" style="display: none;">
                        
                            <input type="hidden" name="tipo2" value="2"/>
                            <div class="control-group">
                                <label class="control-label" for="input01">NOMBRE DEL BANCO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]" name="nom_doc_pago_mat2" value="" id="nom_doc_pago_mat2"/>
                                </div>
                            </div>  

                            <div class="control-group">
                                <label class="control-label" for="input02">NRO DEL CHEQUE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="nro_comp_pago_mat2" value="" id="nro_comp_pago_mat2"/>

                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="input03">FECHA DEL CHEQUE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]] calendario"   name="fecha_doc2" value="" id="fecha_doc2"/>

                                </div>
                            </div>
                            <input type="hidden" name="lote_doc_pago_mat2" value="NINGUNO"/>
                            <input type="hidden" name="monto_efec_doc_pago2" value="0"/>


                            <div class="control-group">
                                <label class="control-label" for="input03">REFERENTE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="ref_doc_pago_mat2" value="" id="ref_doc_pago_mat2"/>

                                </div>
                            </div>    

                            <div class="control-group">
                                <label class="control-label" for="input02">VALOR EN CHEQUE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1],custom[number]]"   name="monto_rest_doc_pago2" value="" id="monto_rest_doc_pago2"/>

                                </div>
                            </div>                        
                            <div class="control-group">

                                <div class="controls">
                                    <a href="#" onclick="return agregarPanel(2);">AGREGAR</a>
                                </div>
                            </div>
                        
                    </div>

                    <div id="panel3" style="display: none;" >
                        
                            <input type="hidden" name="tipo3" value="3"/>
                            <div class="control-group">
                                <label class="control-label" for="input02">NUMERO DE LA CUENTA</label>
                                <div class="controls">
                                    <select  id="select01"  class="span3" name="nom_doc_pago_mat3" id="nom_doc_pago_mat3">
                                        <?php
                                        $ci->load->model('Institucion_Model');
                                        $cuentas = $ci->Institucion_Model->getCuentasInstitucionNombre("INSTITUTO TECNOLOGICO SUPERIOR SUDAMERICANO LOJA");
                                        foreach ($cuentas as $k => $cuenta) {
                                            echo ("<option value='" . $cuenta["cuenta1_inst"] . "'" . (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == $cuenta["cuenta1_inst"] ? " selected" : " ")) . "/>");
                                            echo ($cuenta["cuenta1_inst"] . "-" . $cuenta["banco1_inst"] . "</option>");
                                            echo ("<option value='" . $cuenta["cuenta2_inst"] . "'" . (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == $cuenta["cuenta2_inst"] ? " selected" : " ")) . "/>");
                                            ;
                                            echo ($cuenta["cuenta2_inst"] . "-" . $cuenta["banco2_inst"] . "</option>");
                                            echo ("<option value='" . $cuenta["cuenta3_inst"] . "'" . (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == $cuenta["cuenta3_inst"] ? " selected" : " ")) . "/>");
                                            ;
                                            echo ($cuenta["cuenta3_inst"] . "-" . $cuenta["banco3_inst"] . "</option>");
                                        }
                                        ?>

                                    </select>

                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="input01">NRO DEL DEPOSITO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]" name="nro_comp_pago_mat3" value="" id="nro_comp_pago_mat3">

                                </div>
                            </div>  
                            <input type="hidden" name="lote_doc_pago_mat3" value="NINGUNO">
                            <input type="hidden" name="monto_efec_doc_pago3" value="0">

                            <div class="control-group">
                                <label class="control-label" for="input03">FECHA DEL DEPÓSITO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]] calendario"   name="fecha_doc3" value="" id="fecha_doc3"/>

                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="input03">REFERENTE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="ref_doc_pago_mat3" value="" id="ref_doc_pago_mat3"/>

                                </div>
                            </div>   

                            <div class="control-group">
                                <label class="control-label" for="input02">VALOR EN DEPÓSITO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1],custom[number]]"   name="monto_rest_doc_pago3" value="" id="monto_rest_doc_pago3"/>

                                </div>
                            </div>  
                            <div class="control-group">

                                <div class="controls">
                                    <a href="#" onclick ="return agregarPanel(3);">AGREGAR</a>
                                </div>
                            </div>
                        
                    </div>
                    <div id="panel4" style="display: none;">
                       
                            <input type="hidden" name="tipo4" value="4"/>
                            <div class="control-group">
                                <label class="control-label" for="input01">NOMBRE DE LA TARJETA</label>
                                <div class="controls">
                                    <select id="select01"  name="nom_doc_pago_mat4" id="nom_doc_pago_mat4">
                                        <option value="MASTER CARD" <?php echo (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == "MASTER CARD" ? " selected" : " ")); ?>>MASTER CARD</option>
                                        <option value="DINERS CLUB" <?php echo (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == "DINERS CLUB" ? " selected" : " ")); ?> >DINERS CLUB</option>
                                        <option value="AMERICAN EXPRESS" <?php echo (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == "AMERICAN EXPRESS" ? " selected" : " ")); ?>>AMERICAN EXPRESS</option>
                                        <option value="VISA BANCO AUSTRO" <?php echo (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == "VISA BANCO AUSTRO" ? " selected" : " ")); ?>>VISA BANCO AUSTRO</option>
                                        <option value="VISA BANCO MACHALA" <?php echo (!isset($nom_doc_pago_mat) ? " " : ($nom_doc_pago_mat == "VISA BANCO MACHALA" ? " selected" : " ")); ?>>VISA BANCO MACHALA</option>
                                    </select>
                                </div>
                            </div>


                            <div class="control-group">
                                <label class="control-label" for="input02">NUMERO TARJETA</label>

                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,creditCard]" name="nro_comp_pago_mat4" value="" id="nro_comp_pago_mat4"/>

                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="input03">FECHA DEL PAGO</label>
                                <div class="c0ontrols">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]] calendario"   name="fecha_doc4" value="" id="fecha_doc4"/>

                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="input02">LOTE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="lote_doc_pago_mat4" value="" id="lote_doc_pago_mat4">

                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label" for="input03">REFERENTE</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="ref_doc_pago_mat4" value="" id="ref_doc_pago_mat4"/>

                                </div>
                            </div>
                            <input type="hidden" name="monto_efec_doc_pago4" value="0">
                            <div class="control-group">
                                <label class="control-label" for="input02">VALOR PAGADO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1],custom[number]]"   name="monto_rest_doc_pago4" value="" id="monto_rest_doc_pago4"/>

                                </div>
                            </div>  
                            <div class="control-group">

                                <div class="controls">
                                    <a href="#" onclick ="return agregarPanel(4);">AGREGAR</a>
                                </div>
                            </div>
                        
                    </div>

                    <div id="panel7" style="display: none;">
                        
                       
                            <input type="hidden" name="tipo7" value="7"/>
                            <div class="control-group">
                                <label class="control-label" for="input01">NOMBRE DEL BANCO</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]" name="nom_doc_pago_mat7" value="" id="nom_doc_pago_mat7"/>

                                </div>
                            </div>  

                            <div class="control-group">
                                <label class="control-label" for="input02">NRO DEL TRANSFERENCIA</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]]"   name="nro_comp_pago_mat7" value="" id="nro_comp_pago_mat7"/>

                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="input03">FECHA DEL TRANSFERENCIA</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span2 validate[required,maxSize[60],minSize[1]] calendario"   name="fecha_doc7" value="" id="fecha_doc7"/>

                                </div>
                            </div>
                            <input type="hidden" name="lote_doc_pago_mat7" value="NINGUNO">
                            <input type="hidden" name="ref_doc_pago_mat7" value="NINGUNO">
                            

                            <div class="control-group">
                                <label class="control-label" for="input03">MONTO DEL TRANSFERENCIA</label>
                                <div class="controls">
                                    <input type="text" class="input-medium span1"   name="monto_rest_doc_pago7" value="0" id="monto_rest_doc_pago7"/>

                                </div>
                            </div>  
                            <input type="hidden" name="monto_efec_doc_pago7" value="NINGUNO">
                            
                            <div class="control-group">

                                <div class="controls">
                                    <a href="#" onclick="return agregarPanel(7);">AGREGAR</a>
                                </div>
                            </div>

                        
                    </div>


                    <!--fin-->

                    <!--Tabla de documentos-->
                    <div id="tbldoc" style="overflow: auto">
                        
                    </div>
                    <!--fin de tabla de documentos-->

                    <?php
                    if (!empty($plan_s)) {
                        echo "<input type='hidden' name='coutas_plans' value='" . $plan_s[0]['nro_cuotas_plan'] . "'>";
                        echo "<input type='hidden' name='ide_plans' value='" . $plan_s[0]['ide_plan'] . "'>";
                        ?>
                        <div class="tabbable">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#10" data-toggle="tab">Cuotas adeudadas Semestre</a></li>
                                <li><a href="#11" data-toggle="tab">Cuotas Pagadas Semestre</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="10">

                                    <table id="tabla_cuotas_semestre" class="table table-bordered table-striped tablaVista">
                                        <caption>PLAN SEMESTRAL. VALOR FINANCIADO: <?php echo $plan_s[0]['valor_financiar']; ?>    VALOR PAGADO: <?php echo $totalPagadoS; ?></caption>
                                        <thead>
                                            <tr>
                                                <th>Nro</th>
                                                <th>Couta</th>
                                                <th>Cancela</th>
                                                <th>TOTAL</th>
                                                <th>Reasignar</th>
                                                <th>Observaci&oacute;on</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $cont = 1;
                                            $cuota = "";
                                            //print_r($plan_s);
                                            for ($i = 1; $i <= $plan_s[0]['nro_cuotas_plan']; $i++) {
                                                if ($i <= 5) {
                                                    $cuota = "couta";
                                                } else {
                                                    $cuota = "cuota";
                                                }
                                                if ($plan_s[0]["pagada" . $i] == false) {
                                                    // $verC=($plan_s[0]["pagada" . $i] == true)?'readonly="true"':'';
                                                    if ($this->Coutas_Model->VerificarCoutaCancelada($plan_s[0]['ide_plan'], "canc_cuota" . $i)) {
                                                        echo ("<tr>");
                                                        //echo ("<td> $cont></td>");                                                    
                                                        echo ("<td> $cont></td>");
                                                        //echo ("<td><input readonly='false' value='".$plan_s[0]['couta' . $i . '_plan']."' /></td>");
                                                    } else {
                                                        ?>
                                                        <tr>
                                                            <td><input type="checkbox"  name="<?php echo ("opt" . $i . "_plans"); ?>" id="<?php echo ("opt" . $i . "_plans"); ?>" value="<?php echo ("pago" . $i . "_plans"); ?>" ONCHANGE="cambiarvalor(document.getElementById('<?php echo ("opt" . $i . "_plans"); ?>'),document.getElementById('<?php echo ("couta" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plans"); ?>'))"/> <?php echo $cont ?></td>
                                                        <?php } ?>
                                                        <td><input readonly="true" value="<?php echo $plan_s[0][$cuota . $i . "_plan"]; ?>" style="width: 40px;" name="<?php echo ("couta" . $i . "_plans"); ?>" id="<?php echo ("couta" . $i . "_plans"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plans"); ?>'))"/></td>

                                                        <td><input value="0" style="width: 40px;" name="<?php echo ("pago" . $i . "_plans"); ?>" id="<?php echo ("pago" . $i . "_plans"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plans"); ?>'))"/></td>
                                                        <td><input readonly="true" value="" style="width: 40px;" name="<?php echo ("total" . $i . "_plans"); ?>" id="<?php echo ("total" . $i . "_plans"); ?>"  /></td>
                                                        <?php if ($i < $plan_s[0]['nro_cuotas_plan']) { ?>
                                                            <td><input type='button' name="<?php echo ("boton" . $i . "_plans"); ?>"  onclick="refinancia(document.getElementById('<?php echo ("couta" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plans"); ?>'), document.getElementById('<?php echo ("couta" . ($i + 1) . "_plans"); ?>'))" value='Recals'></td>
                                                        <?php } else { ?>
                                                            <td> </td>
                                                        <?php } ?>

                                                        <td><textarea  name="<?php echo ("obs" . $i . "_plans"); ?>"  id="<?php echo ("obs" . $i . "_plans"); ?>"  class="validate[maxSize[100],minSize[1]]"> </textarea></td>
                                                    </tr>

                                                    <?php
                                                }
                                                $cont++;
                                                /**/
                                            }
                                            ?>
                                        </tbody>
                                    </table>     
                                </div>
                                <div class="tab-pane" id="11">


                                    <table class="table table-bordered table-striped tablaVista">
                                        <caption>TOTAL PLAN SEMESTRAL PAGADO: <?php echo($totalPagadoS); ?></caption>
                                        <thead>
                                            <tr>
                                                <th>Nro</th>
                                                <th>Valor Couta</th>                                            
                                                <th>Fecha</th>                                            
                                                <th>Observaci&oacute;on</th>
                                                <th>Acciones</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $cont = 1;
                                            //print_r($plan_s);
                                            foreach ($plan_s_p as $item) {
                                                echo '<tr>';
                                                echo '<td>' . $item["nro_cuota"] . '</td>';
                                                echo '<td>' . $item["valor"] . '</td>';
                                                echo '<td>' . $item["fecha_pago"] . '</td>';
                                                echo '<td>' . $item["observacion"] . '</td>';
                                                echo '<td>';
                                                if ($cont == (count($plan_s_p))) {
                                                    echo anchor('coutas/eliminar/' . $item["ide_canc"] . '/s/' . $ide_matr, img(array('src' => 'commons/images/Bin_Empty.png', 'alt' => 'Eliminar', 'title' => 'Eliminar', 'width' => '16px', 'height' => '16px')), array('title' => 'Eliminar', 'onclick' => "return confirm('Esta seguro de eliminar esta cuota')"));
                                                } else {
                                                    echo img(array('src' => 'commons/images/Stop.png', 'alt' => 'Sin acciones', 'title' => 'Sin acciones', 'width' => '16px', 'height' => '16px'));
                                                }

                                                echo '</td>';
                                                echo '<tr>';
                                                $cont++;
                                            }
                                            ?>
                                        </tbody>
                                    </table>     

                                </div>
                            </div>
                        </div>
                        <?php
                    }

                    if (!empty($plan_a)) {
                        echo "<input type='hidden' name='coutas_plana' value='" . $plan_a[0]['nro_cuotas_plan'] . "'>";
                        echo "<input type='hidden' name='ide_plana' value='" . $plan_a[0]['ide_plan'] . "'>";
                        ?>
                        <div class="tabbable">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#20" data-toggle="tab">Cuotas adeudadas Arrastre</a></li>
                                <li><a href="#21" data-toggle="tab">Cuotas Pagadas Arrastre</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="20">
                                    <table id="tabla_cuotas_arrastre" class="table table-bordered table-striped tablaVista">
                                        <caption>PLAN ARRASTRE. VALOR FINANCIADO: <?php echo round(($plan_a[0]['valor_financiar'] - $totalPagadoA), 2); ?></caption>
                                        <thead>
                                            <tr>
                                                <th>Nro</th>
                                                <th>Couta</th>
                                                <th>Cancela</th>
                                                <th>TOTAL</th>
                                                <th>Reasignar</th>
                                                <th>Observaci&oacute;on</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $cont = 1;
                                            //print_r($plan_s);
                                            for ($i = 1; $i <= $plan_a[0]['nro_cuotas_plan']; $i++) {
                                                if ($plan_a[0]["pagada" . $i] == false) {
                                                    ?>
                                                    <tr>
                                                        
                                                        <td><input type="checkbox" name="<?php echo ("opt" . $i . "_plana"); ?>" id="<?php echo ("opt" . $i . "_plana"); ?>" value="<?php echo ("pago" . $i . "_plana"); ?>" onclick="cambiarvalor(document.getElementById('<?php echo ("opt" . $i . "_plana"); ?>'),document.getElementById('<?php echo ("couta" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plana"); ?>'))"/><?php echo $cont ?></td>
                                                        <td><input readonly="true" value="<?php echo $plan_a[0]["couta" . $i . "_plan"]; ?>" style="width: 40px;" name="<?php echo ("couta" . $i . "_plana"); ?>" id="<?php echo ("couta" . $i . "_plana"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plana"); ?>'))"/></td>
                                                        <td><input value="0" style="width: 40px;" name="<?php echo ("pago" . $i . "_plana"); ?>" id="<?php echo ("pago" . $i . "_plana"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plana"); ?>'))"/></td>
                                                        <td><input readonly="true" value="" style="width: 40px;" name="<?php echo ("total" . $i . "_plana"); ?>" id="<?php echo ("total" . $i . "_plana"); ?>"  /></td>
                                                        <?php if ($i < $plan_a[0]['nro_cuotas_plan']) { ?>
                                                            <td><input type='button' name="<?php echo ("boton" . $i . "_plana"); ?>"  onclick="refinancia(document.getElementById('<?php echo ("couta" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plana"); ?>'), document.getElementById('<?php echo ("couta" . ($i + 1) . "_plana"); ?>'))" value='Recals'></td>
                                                        <?php } else { ?>
                                                            <td> </td>
                                                        <?php } ?>
                                                        <td><textarea  name="<?php echo ("obs" . $i . "_plana"); ?>"  id="<?php echo ("obs" . $i . "_plana"); ?>"  class="validate[maxSize[100],minSize[1]]"> </textarea></td>
                                                    </tr>

                                                    <?php
                                                }
                                                $cont++;
                                            }
                                            ?>
                                        </tbody>
                                    </table>  
                                </div>
                                <div class="tab-pane" id="21">


                                    <table class="table table-bordered table-striped tablaVista">
                                        <caption>TOTAL PLAN ARRASTRE PAGADO: <?php echo($totalPagadoA); ?></caption>
                                        <thead>
                                            <tr>
                                                <th>Nro</th>
                                                <th>Valor Couta</th>                                            
                                                <th>Fecha</th>                                            
                                                <th>Observaci&oacute;on</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $cont = 1;
                                            //print_r($plan_s);
                                            foreach ($plan_a_p as $item) {
                                                echo '<tr>';
                                                echo '<td>' . $item["nro_cuota"] . '</td>';
                                                echo '<td>' . $item["valor"] . '</td>';
                                                echo '<td>' . $item["fecha_pago"] . '</td>';
                                                echo '<td>' . $item["observacion"] . '</td>';
                                                echo '<td>';
                                                if ($cont == (count($plan_a_p))) {
                                                    echo anchor('coutas/eliminar/' . $item["ide_canc"] . '/a/' . $ide_matr, img(array('src' => 'commons/images/Bin_Empty.png', 'alt' => 'Eliminar', 'title' => 'Eliminar', 'width' => '16px', 'height' => '16px')), array('title' => 'Eliminar', 'onclick' => "return confirm('Esta seguro de eliminar esta cuota')"));
                                                } else {
                                                    echo img(array('src' => 'commons/images/Stop.png', 'alt' => 'Sin acciones', 'title' => 'Sin acciones', 'width' => '16px', 'height' => '16px'));
                                                }

                                                echo '</td>';
                                                echo '<tr>';
                                                $cont++;
                                            }
                                            ?>
                                        </tbody>
                                    </table>     

                                </div>
                            </div>
                        </div>
                        <?php
                    }
                    /* if (!empty($plan_t)) {
                      echo "<input type='hidden' name='coutas_plant' value='" . $plan_t[0]['nro_cuotas_plan'] . "'>";
                      echo "<input type='hidden' name='ide_plant' value='" . $plan_t[0]['ide_plan'] . "'>"; */
                    ?>

                    <!--
                    
                                            <table class="table table-bordered table-striped tablaVista">
                                                <caption>PLAN TESIS, VALOR FINANCIADO: <?php echo($plan_t[0]['valor_financiar']); ?></caption>
                                                <thead>
                                                    <tr>
                                                        <th>Nro</th>
                                                        <th>Couta</th>
                                                        <th>Cancela</th>
                                                        <th>TOTAL</th>
                                                        <th>Reasignar</th>
                                                        <th>Observaci&oacute;on</th>
                                                    </tr>
                                                </thead>
                                                <tbody>-->
                    <?php
                    /* $cont = 1;

                      for ($i = 1; $i <= $plan_t[0]['nro_cuotas_plan']; $i++) { */
                    ?>
                                                     <!--   <tr>
                                                        <tr>
                                                            <td><input type="checkbox" name="<?php echo ("opt" . $i . "_plant"); ?>" id="<?php echo ("opt" . $i . "_plant"); ?>" value="<?php echo ("couta" . $i . "_plant"); ?>" /><?php echo $cont ?></td>
                                                            <td><input readonly="true" value="<?php echo $plan_t[0]["couta" . $i . "_plant"]; ?>" style="width: 40px;" name="<?php echo ("couta" . $i . "_plant"); ?>" id="<?php echo ("couta" . $i . "_plant"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plant"); ?>'))"/></td>
                                                            <td><input value="0" style="width: 40px;" name="<?php echo ("pago" . $i . "_plant"); ?>" id="<?php echo ("pago" . $i . "_plant"); ?>"  class="validate[required,maxSize[8],minSize[1],custom[number],min[0],max[10000]]" onkeyup="sumar(document.getElementById('<?php echo ("couta" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plant"); ?>'))"/></td>
                                                            <td><input readonly="true" value="" style="width: 40px;" name="<?php echo ("total" . $i . "_plant"); ?>" id="<?php echo ("total" . $i . "_plant"); ?>"  /></td>
                    <?php if ($i < $plan_t[0]['nro_cuotas_plan']) { ?>
                                                                                                        <td><input type='button' name="<?php echo ("boton" . $i . "_plant"); ?>"  onclick="refinancia(document.getElementById('<?php echo ("couta" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("pago" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("total" . $i . "_plant"); ?>'), document.getElementById('<?php echo ("couta" . ($i + 1) . "_plant"); ?>'))" value='Recals'></td>
                    <?php } else { ?>
                                                                                                        <td> </td>
                    <?php } ?>
                                                            <td><textarea  name="<?php echo ("obs" . $i . "_plant"); ?>"  id="<?php echo ("obs" . $i . "_plant"); ?>"  class="validate[maxSize[100],minSize[1]]"> </textarea></td>
                    
                                                        </tr>-->

                    <?php
                    /* $cont++;
                      } */
                    ?>
                    </tbody>
                    </table>        

                    <?php
                    //  }
                    ?>
                    <div class="control-group">
                        <label class="control-label" for="input02">Valor A cancelar</label>
                        <div class="controls">
                            <input  readonly="true" value="" style="width: 40px;" name="cancelar" id="cancelar" class="validate[required,maxSize[8],minSize[1],custom[number],min[1],max[10000]]"  />
                            <input type="button" name="buttoncalc" id="buttoncalc" onclick="Acancelar()" value="calcular">

                        </div>
                    </div>

                    <div class="controls">
                        
                        <?php if ($imprime == ''||$imprime == 'n') { ?>
                            <button type="submit" class="btn">Grabar Cobros</button>

                            <a href="<?php echo base_url() . "admin.php/coutas/inicio/".$ide_lec ?>">
                                <img src="<?php echo base_url(); ?>commons/images/boton_volver.gif"></a>
                        <?php } else { ?>
                            <a href="<?php echo base_url() . "admin.php/coutas/imprimir" ?>" target="_blank">
                                <img src="<?php echo base_url(); ?>commons/images/imprimir.gif"></a>

                            <a href="<?php echo base_url() . "admin.php/coutas/inicio" ?>">
                                <img src="<?php echo base_url(); ?>commons/images/boton_volver.gif"></a>


                        <?php } ?>
                              <a href="<?php echo base_url() . "admin.php/coutas/presentardatos/". $ide_matr ?>">
                                CERTIFICADO</a>

                    </div> 
                </form>
            </div><!--fin tabulador 3 -->
            <!--inicio tabulador 4 -->
            <div class="tab-pane" id="4">
                <script>
                    var t = jQuery.noConflict();
                    function cargarVista(name, auxi, tipo) {
                        var id_asigna = name;
                        var selec = confirm(auxi);
                        if (selec == true) {
                            if (id_asigna == '') {
                                t('#table_rubro').html("No existe ");
                            } else {
                                var url = '<?php echo base_url(); ?>';


                                t.ajax({
                                    type: 'POST', url: '<?php echo base_url(); ?>admin.php/coutas/pagarValor/',
                                    data: 'ide_asigna=' + id_asigna + '&estado=' + tipo + '&id_matricula=' +<?php echo $ide_matr; ?>,
                                    dataType: 'html',
                                    success: (function(data) {
                                        //  alert(data);
                                        t('#tablaRC tbody').html(data);
                                    }),
                                    beforeSend: function(objeto) {
                                        t('#cargar').html('<img id="cargar" src="' + url + 'commons/images/loading.gif"/>');
                                    },
                                    complete: function(objeto) {
                                        t('#cargar').html('<img id="cargar" style="display:none"/>');
                                    }
                                });
                            }
                        }
                    }

                </script>




                <table id="tablaR" class="table table-bordered table-striped tablaVista">
                    <thead>
                    <th>Nro</th><th>Nombre rubro</th><th>Costo</th><th>Estado</th><th>Acciones</th>
                    </thead>
                    <tbody>
                        <?php
                        if (count($lista_rubro) > 0) {
                            $c = 1;
                            foreach ($lista_rubro as $item) {                                
                                $estado = $item["estado_asigna"];
                                $aux = ($estado == 1) ? 'ADEUDA' : 'CANCELADO';
                                echo '<tr>';
                                echo '<td>' . $c . '</td>';
                                echo '<td>' . $item["nombre_rubro"] . '</td>';
                                echo '<td>' . $item["costo_rubro"] . '</td>';
                                echo '<td>' . $aux . '</td>';
                                echo '<td>';
                                if($item["estado_asigna"]==true){
                                    if($item["nro_cuota"]==0){
                                        echo "<script>
                                            var t =  jQuery.noConflict();
                                            t(function() {
                                                t('#rc_" . $item["ide_asigna"] ."').click(function(event){
                                                    
                                                    var id_asigna = ".$item["ide_asigna"].";
                                                   
                                                    t.ajax({
                                                        type: 'POST', 
                                                        url: '".  base_url()."admin.php/coutas/crearPanelCuotasRubro/',
                                                        data: 'id=' + id_asigna + '&ide_matr='+".$ide_matr." + '&ide_lec='+".$ide_lec.",
                                                        dataType: 'html',
                                                        success: (function(data) {
                                                            
                                                            t('#panel').html(data);
                                                        })
                                                    });
                                                });
                                            });
                                        </script>"
                                        ;
                                        echo '<input id="rc_'.$item["ide_asigna"].'" type="button" value="Generar Cuotas"/>';
                                        
                                    }else{
                                        echo "<script>
                                            var t =  jQuery.noConflict();
                                            t(function() {
                                                t('#pc_" . $item["ide_asigna"] ."').click(function(event){                                                    
                                                    var id_asigna = ".$item["ide_asigna"].";                                                   
                                                    t.ajax({
                                                        type: 'POST', 
                                                        url: '".  base_url()."admin.php/coutas/verPanelCuotasRubro/',
                                                        data: 'id=' + id_asigna,
                                                        dataType: 'html',
                                                        success: (function(data) {
                                                            //alert(data);
                                                            t('#panel').html(data);
                                                        })
                                                    });
                                                });
                                            });
                                        </script>"
                                        ;
                                        echo '<input id="pc_'.$item["ide_asigna"].'" type="button" value="Pagar" class="btn btn-info"/></br></br>';
                                        echo '<a href="'.  base_url().'admin.php/coutas/verListarImprimirCuotasRubro/'.$item["ide_asigna"].'" class="btn btn-info" target="_blank">Imprimir Recibo</a>';
                                    }
                                }else{
                                    echo 'YA CANCELO</br>';
                                    echo '<a href="'.  base_url().'admin.php/coutas/verListarImprimirCuotasRubro/'.$item["ide_asigna"].'" class="btn btn-info" target="_blank">Imprimir Recibo</a>';
                                }
                                echo '</td>';
                                echo '</tr>';
                                $c++;
                            }
                        }
                        ?>
                    </tbody>
                </table>
                 <!--   <a href="<?php echo base_url() . "admin.php/asignar_rubro_controlador/listado/".$ide_lec."/".$lista_rubro[0]["ide_rubro"] ?>">
                    <img src="<?php echo base_url(); ?>commons/images/boton_volver.gif"></a>-->

                
                <div id="panel"  style="margin-left: auto; margin-right: auto;"></div>
                <div id="cargar"></div>

 <a href="<?php echo base_url() . "admin.php/asignar_rubro_controlador/listado/".$ide_lec."/".(isset($lista_rubro[0]["ide_rubro"])?$lista_rubro[0]["ide_rubro"]:1) ?>">
                    <img src="<?php echo base_url(); ?>commons/images/boton_volver.gif"></a>
            </div>
            <!--Para pagos inicial-->
            <script>
                var t = jQuery.noConflict();
                t(document).ready(function() {
                    t("#inputValor").keyup(function() {
                        verificarCoutaInicial();
                    });
                    t("#nro_coutas_inicial").change(function() {
                        verificarCoutaInicial();
                    });
                });
                function verificarCoutaInicial() {
                    var nro_couta = t('#nro_coutas_inicial').val();
                    var aux = t("#inputValor").val();
                    var couta = <? echo $plan_s[0]['couta1_plan']; ?>;
                    var boton = t('#enviado');
                    var msg = t('#mensaje');
                    couta = couta * nro_couta;
                    if (aux > couta) {
                        // alert(couta+" "+aux);
                        boton.attr("disabled", "true");
                        msg.html("<span style='color:red; font-size:12;'>El pago inicial supera la cuota. Debe escoger mas numeros de coutas</span>");
                    } else {
                        msg.html("");
                        boton.removeAttr("disabled");
                    }
                }
            </script>

            <?php if ($totalPagadoS == 0) { ?>
                <div class="tab-pane" id="5">                    
                    <form id="formID3" class="well form-horizontal span8" action="<?php echo base_url() . "admin.php/coutas/recalcularCuotas/" . $ide_matr ?>"  method="post" >
                        <div class="control-group">

                            <div class="control-group">
                                <label class="control-label" for="nro_ant">Nro cuotas pagadas</label>
                                <div class="controls">
                                    <input type="text" id="nro_ant" name="nro_ant" class="input-medium span2 validate[required,[number],maxSize[60],minSize[1]]" value="<?php echo $nro_coutas_pagadas; ?>" readonly="true"/>
                                </div>
                            </div> 

                            <div class="control-group">
                                <label class="control-label" for="pago_ant">Valor inicial pagado anterior</label>
                                <div class="controls">
                                    <input type="text" id="pago_ant" name="pago_ant" class="input-medium span2 validate[required,[number],maxSize[60],minSize[1]]" value="<?php echo $valor_inicial_pagado; ?>"  readonly="true"/>
                                </div>
                            </div> 

                            <div class="control-group">
                                <label class="control-label" for="nro_coutas_inicial">Nro de cuotas</label>

                                <div class="controls">
                                    <select name="nro_coutas_inicial" id="nro_coutas_inicial">
                                        <?php
                                        for ($i = 1; $i <= $plan_s[0]['nro_cuotas_plan']; $i++) {
                                            echo '<option value="' . $i . '">' . $i . '</option>';
                                        }
                                        ?>
                                    </select>

                                </div>
                            </div> 
                            <div class="control-group">
                                <label class="control-label" for="inputValor">Valor inicial</label>
                                <div class="controls">
                                    <input type="text" id="inputValor" name="inputValor" class="input-medium span2 validate[required,[number],maxSize[60],minSize[1],min[1]]"/>
                                </div>
                            </div> 
                            <div id="mensaje"></div>
                            <div class="controls">

                                <button type="submit" id="enviado" class="btn">Recalcular</button>



                            </div> 
                        </div>
                    </form>
                </div>
            <?php } ?>
            <!--  REFINANCIAMIENTO -->
            <?php //if ($totalPagadoS <= $plan_s[0]['valor_financiar']) {  ?>
            <div class="tab-pane" id="6">
                <script>
                    //var t = jQuery.noConflict();
                    function cargarNroRef() {
                        var tipo = t("#tipo_ref").find(':selected').val();
                        var num = '';
                        //t('#nro_ref').html();
                        if (tipo == 'semestre') {
                            num = <?php echo count($plan_s_p); ?>
                        } else if (tipo == 'arrasstre') {
                            num = <?php echo count($plan_a_p); ?>
                        }
                        var url = '<?php echo base_url(); ?>';
                        t('#tref').html("Elija las opciones");
                        t.ajax({
                            type: 'POST',
                            url: '<?php echo base_url(); ?>admin.php/coutas/verNroRefina/',
                            data: 'tipo=' + tipo + '&num=' + num,
                            dataType: 'html',
                            success: (function(data) {
                                //alert(data);                                 
				t('#nro_ref').html(data);
                            }),
                            beforeSend: function(objeto) {
                                t("#cargar1").html('<img  src="' + url + 'commons/images/loading.gif"/>');
                            },
                            complete: function(objeto) {
                                t("#cargar1").html('<img  style="display:none"/>');
                            }
                        });


                    }
                    t(function() {
                        t("#tipo_ref").change(function(event)
                        {

                            cargarNroRef();
                        });
                    });

                    function cargarTablaRefina() {
                        var tipo = t("#tipo_ref").find(':selected').val();
                        var num = t("#nro_ref").find(':selected').val();
                        var mat = <?php echo $ide_matr; ?>;
                        var url = '<?php echo base_url(); ?>';
                        t('#tref').html("Elija las opciones");
                        t.ajax({
                            type: 'POST',
                            url: '<?php echo base_url(); ?>admin.php/coutas/verTablaRefina/',
                            data: 'tipo=' + tipo + '&nro=' + num + '&ide_mat=' + mat,
                            dataType: 'html',
                            success: (function(data) {
                                //alert(data);
                                t('#tref').html(data);
                                
                            }),
                            beforeSend: function(objeto) {
                                t("#cargar1").html('<img  src="' + url + 'commons/images/loading.gif"/>');
                            },
                            complete: function(objeto) {
                                t("#cargar1").html('<img  style="display:none"/>');
                            }
                        });
                        //tref
                    }
                    t(function() {
                        t("#nro_ref").change(function(event)
                        {
				//alert("hola");
                            cargarTablaRefina();
                        });
                    });
                </script>
                <form id="formID3" class="well form-horizontal span8" action="<?php echo base_url() . "admin.php/coutas/refinanciar/" . $ide_matr ?>"  method="post" >
                    <input type="hidden" name="ide_matref" value="<?php echo $ide_matr; ?>">
                    <div class="control-group">
                        <div class="control-group">
                            <label class="control-label" for="tipo_ref">Que desea refinanciar?</label>
                            <div class="controls">
                                <select id="tipo_ref" name="tipo_ref" class="input-medium span2 validate[required]">

                                    <?php
                                    echo '<option value="">Seleccione</option>';
                                    if (count($plan_s) > 0) {
                                        echo '<option value="semestre">Semestre</option>';
                                    }
                                    if (count($plan_a) > 0) {
                                        echo '<option value="arrastre">Arrastre</option>';
                                    }
                                    ?>

                                </select>

                            </div>
                        </div> 

                        <div class="control-group">
                            <label class="control-label" for="nro_ref">Nro cuotas a refinanciar</label>
                            <div class="controls">
                                <select id="nro_ref" name="nro_ref" class="input-medium span2 validate[required,[number],maxSize[60],minSize[1]]">                                        
                                    <option value="">Seleccione</option>
                                </select>

                            </div>
                        </div> 




                        <div class="control-group">
                            <div id="tref"></div>

                        </div> 

                    </div>
                </form>
            </div>
            <?php //}  ?>
        </div>

        <?php if (isset($msj_error)) { ?>
            <div class='MensajeError'>
                <?php echo ($msj_error); ?>
            </div>
        <?php } ?>

        <fieldset>
            <div class="control-group"> 
                <div class="controls">
                    <input type="hidden" name="ide_est" value="<?php echo $est["ide_est"]; ?>">
                    <input type="hidden" id="ide_matricula" name="ide_matr" value="<?php echo $ide_matr; ?>">
                    <input type="hidden" name="nro_matr" value="<?php echo $nro_mat; ?>">
                    
                </div>
            </div >
        </fieldset>
    </div>
